package com.zfxt.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2018/9/2.//Springboot异常处理器
 */
@ControllerAdvice
public class ErrorHandler {
    private static final Logger logger= LoggerFactory.getLogger(ErrorHandler.class);
    @ExceptionHandler(value = {Exception.class,RuntimeException.class})
    public String error500(HttpServletRequest request ,Exception e){
        logger.error(e.getMessage(),e);
        logger.error(request.getRequestURI()+"encouter 500");
        return "error/500";
    }
}
